<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
        xmlns:jsr107='http://www.ehcache.org/v3/jsr107'
        xmlns="http://www.ehcache.org/v3"
        xsi:schemaLocation="http://www.ehcache.org/v3 http://www.ehcache.org/schema/ehcache-core-3.0.xsd
                            http://www.ehcache.org/v3/jsr107 http://www.ehcache.org/schema/ehcache-107-ext-3.0.xsd">
    <service>
        <jsr107:defaults jsr-107-compliant-atomics="true" enable-management="true" enable-statistics="true"/>
    </service>

    <!--default-copiers>
        <copier type="com.serotonin.mango.view.View">org.scada_lts.dao.cache.ViewCopier</copier>
    </default-copiers-->

    <cache-template name="list_cache_template">
        <key-type>java.lang.Integer</key-type>
        <value-type>java.util.List</value-type>
        <expiry>
            <none/>
        </expiry>
        <heap>200</heap>
    </cache-template>

    <cache-template name="string_list_cache_template">
        <key-type>java.lang.String</key-type>
        <value-type>java.util.List</value-type>
        <expiry>
            <none/>
        </expiry>
        <heap>200</heap>
    </cache-template>

    <cache-template name="integer_alarm_level_template">
        <key-type>java.lang.Integer</key-type>
        <value-type>org.scada_lts.dao.model.UserAlarmLevel</value-type>
        <expiry>
            <none/>
        </expiry>
        <heap>200</heap>
    </cache-template>

    <cache-template name="integer_list_exp_ttl_heap_max_bytes_cache_template" >
        <key-type>java.lang.Integer</key-type>
        <value-type>java.util.List</value-type>
        <expiry>
            <ttl unit="seconds">3600</ttl>
        </expiry>
        <resources>
            <heap unit="MB">50</heap>
        </resources>
    </cache-template>

    <cache-template name="long_list_exp_ttl_heap_max_bytes_cache_template" >
        <key-type>java.lang.Long</key-type>
        <value-type>java.util.List</value-type>
        <expiry>
            <ttl unit="seconds">3600</ttl>
        </expiry>
        <resources>
            <heap unit="MB">50</heap>
        </resources>
    </cache-template>

    <cache-template name="integer_view_template">
        <key-type>java.lang.Integer</key-type>
        <value-type>com.serotonin.mango.view.View</value-type>
        <expiry>
            <none/>
        </expiry>
        <heap>200</heap>
    </cache-template>

    <cache-template name="string_view_template">
        <key-type>java.lang.String</key-type>
        <value-type>com.serotonin.mango.view.View</value-type>
        <expiry>
            <none/>
        </expiry>
        <heap>200</heap>
    </cache-template>

    <cache-template name="integer_point_event_detector_list_template">
        <key-type>java.lang.Integer</key-type>
        <value-type>java.util.List</value-type>
        <expiry>
            <none/>
        </expiry>
        <resources>
            <heap unit="MB">100</heap>
        </resources>
    </cache-template>

    <cache-template name="integer_point_event_detector_template">
        <key-type>java.lang.Integer</key-type>
        <value-type>com.serotonin.mango.vo.event.PointEventDetectorVO</value-type>
        <expiry>
            <none/>
        </expiry>
        <resources>
            <heap unit="MB">100</heap>
        </resources>
    </cache-template>

    <cache-template name="string_point_event_detector_template">
        <key-type>java.lang.String</key-type>
        <value-type>com.serotonin.mango.vo.event.PointEventDetectorVO</value-type>
        <expiry>
            <none/>
        </expiry>
        <resources>
            <heap unit="MB">100</heap>
        </resources>
    </cache-template>

    <cache-template name="integer_integer_cache_template">
        <key-type>java.lang.Integer</key-type>
        <value-type>java.lang.Integer</value-type>
        <expiry>
            <none/>
        </expiry>
        <resources>
            <heap unit="MB">100</heap>
        </resources>
    </cache-template>

    <cache-template name="string_list_cache_heap_max_bytes_template">
        <key-type>java.lang.String</key-type>
        <value-type>java.util.List</value-type>
        <expiry>
            <none/>
        </expiry>
        <resources>
            <heap unit="MB">100</heap>
        </resources>
    </cache-template>

    <!-- user -->
    <cache alias="user_list" uses-template="string_list_cache_template"/>

    <!-- profile -->
    <cache alias="profile_list_offset_limit" uses-template="string_list_cache_template"/>
    <cache alias="profile_list_by_userid" uses-template="list_cache_template"/>
    <cache alias="userid_list_by_profileid" uses-template="list_cache_template"/>

    <!-- share user -->
    <cache alias="share_user_list_by_view" uses-template="string_list_cache_template"/>
    <cache alias="share_user_list_by_watchlist" uses-template="string_list_cache_template"/>

    <!-- permission by user -->
    <cache alias="permission_datasource_list_by_user" uses-template="list_cache_template"/>
    <cache alias="permission_datapoint_list_by_user" uses-template="list_cache_template"/>
    <cache alias="permission_view_list_by_user" uses-template="list_cache_template"/>
    <cache alias="permission_watchlist_list_by_user" uses-template="list_cache_template"/>

    <!-- permission by profile -->
    <cache alias="permission_datasource_list_by_profile" uses-template="list_cache_template"/>
    <cache alias="permission_datapoint_list_by_profile" uses-template="list_cache_template"/>
    <cache alias="permission_view_list_by_profile" uses-template="list_cache_template"/>
    <cache alias="permission_watchlist_list_by_profile" uses-template="list_cache_template"/>

    <cache alias="alarmlevel_highest_by_user" uses-template="integer_alarm_level_template"/>

    <!-- user comment -->
    <cache alias="comment_list_by_pointid" uses-template="integer_list_exp_ttl_heap_max_bytes_cache_template"/>
    <cache alias="comment_list_by_eventid" uses-template="integer_list_exp_ttl_heap_max_bytes_cache_template"/>
    <cache alias="comment_event_list" uses-template="string_list_cache_heap_max_bytes_template"/>

    <!-- view -->
    <cache alias="view_list" uses-template="string_list_cache_template"/>
    <cache alias="view_by_id" uses-template="integer_view_template"/>

    <cache alias="point_event_detector_list_by_data_point_id" uses-template="integer_point_event_detector_list_template"/>
    <cache alias="point_event_detector" uses-template="integer_point_event_detector_template"/>
    <cache alias="point_event_detector_by_xid_and_data_point_id" uses-template="string_point_event_detector_template"/>
    <cache alias="data_point_id_by_point_event_detector_id" uses-template="integer_integer_cache_template"/>
</config>
